package com.cpi.basilos.corntype.converter;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.apache.commons.collections.CollectionUtils;

import com.cpi.basilos.corntype.dto.CornTypeDTO;
import com.cpi.basilos.corntype.view.CornTypeView;

/**
 * Corn Type Converter
 * 
 * @author joao
 *
 */
public class CornTypeConverter {

	public CornTypeView convertDTOToView(CornTypeDTO dto){
		CornTypeView view = null;
		if(dto != null){
			view = new CornTypeView();
			view.setCornTypeId(dto.getCornTypeId());
			view.setDescription(dto.getDescription());
			view.setFeatures(dto.getFeatures());
			view.setShortName(dto.getShortName());
			view.setBaanCode(dto.getBaanCode());			
		}
		return view;
	}
	
	public List convertDTOsToViews(List dtos){
		List views = new ArrayList(0);
		if(CollectionUtils.isEmpty(dtos)){
			Iterator iterator = dtos.iterator();
			CornTypeDTO dto = null;
			while(iterator.hasNext()){
				dto = (CornTypeDTO) iterator.next();
				views.add(convertDTOToView(dto));
			}
		}
		return views;
	}
	
}
